﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace WebApplication2.Filters
{
    public class LoginFilterAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            //需求:1 判断session是否有值;
            if (filterContext.HttpContext.Session["user"] == null)
            {
                //1.1 没有值，就跳转到登录页面
                filterContext.HttpContext.Response.Redirect("/Login/Index");
            }
        }
    }
}